package com.ostrich.cloud.ostrichUserWeb.app.ApiImp;



import cn.hutool.core.bean.BeanUtil;
import com.ostrich.cloud.common.result.Result;
import com.ostrich.cloud.ostrichUserService.client.BusinessmanMangerClient;
import com.ostrich.cloud.ostrichUserService.client.CustomerMangerClient;
import com.ostrich.cloud.ostrichUserWeb.client.CustomerWebMangerClient;
import com.ostrich.cloud.ostrichUserWeb.client.userparam.CusPasswordWebParam;
import com.ostrich.cloud.ostrichUserWeb.client.userparam.LoginCusWebParam;
import com.ostrich.cloud.ostrichUserWeb.client.userparam.RegCustomerWebParam;
import com.ostrich.cloud.ostrichUserWeb.client.userparam.UpdateCusWebParam;
import com.ostrich.ostrichUserService.param.CusPasswordParam;
import com.ostrich.ostrichUserService.param.LoginCusParam;
import com.ostrich.ostrichUserService.param.RegCustomerParam;
import com.ostrich.ostrichUserService.param.UpdateCusParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;
import java.math.BigDecimal;

@RestController
public class CustomerWebApiImp implements CustomerWebMangerClient {
    @Resource
    private CustomerMangerClient customerMangerClient;
    @Resource
    private BusinessmanMangerClient businessmanMangerClient;
    @Override
    public Result customerRegister(@Valid RegCustomerWebParam regCustomerWebParam) {
        RegCustomerParam regCustomerParam = BeanUtil.copyProperties(regCustomerWebParam, RegCustomerParam.class);
        return customerMangerClient.customerRegister(regCustomerParam);
    }

    @Override
    public Result uploadCusImg(MultipartFile file) throws IOException {
        return customerMangerClient.uploadCusImg(file);
    }

    @Override
    public Result updateCusMessage(UpdateCusWebParam updateCusWebParam) {
        UpdateCusParam updateCusParam = BeanUtil.copyProperties(updateCusWebParam, UpdateCusParam.class);
        return customerMangerClient.updateCusMessage(updateCusParam);
    }

    @Override
    public Result getCusMessage() {
        return customerMangerClient.getCusMessage();
    }

//    @Override
//    public Result getAllCusMessage(Integer current, Integer size, String status) {
//        return customerMangerClient.getAllCusMessage(current, size, status);
//    }

    @Override
    public Result customerLogin(LoginCusWebParam loginCusWebParam) {
        LoginCusParam loginCusParam = BeanUtil.copyProperties(loginCusWebParam, LoginCusParam.class);
        Result result = customerMangerClient.customerLogin(loginCusParam);
        return result;

    }

    @Override
    public Result cusPasswordUp(CusPasswordWebParam cusPasswordWebParam) {
        CusPasswordParam cusPasswordParam = BeanUtil.copyProperties(cusPasswordWebParam, CusPasswordParam.class);
        return customerMangerClient.cusPasswordUp(cusPasswordParam);
    }

    @Override
    public Result upCusStatus(Integer parentId, String status) {
        return customerMangerClient.upCusStatus(parentId, status);
    }

    @Override
    public Result pay(Double price) {
        return customerMangerClient.pay(price);
    }

    @Override
    public Result updateMoney(BigDecimal price) {
        return customerMangerClient.updateMoney(price);
    }

    @Override
    public Result getAllBusinessByLocation(String latitude, String logitud, Double radius) {
        return businessmanMangerClient.getAllBusinessByLocation(latitude, logitud, radius);
    }

    @Override
    public Result getOneBusinessByLocation(String latitude, String logitud) {
        return businessmanMangerClient.getOneBusinessByLocation(latitude, logitud);
    }


}
